<?php

if (!UserController::isLoggedAdmin()) {
            throw new Exception('Access denied!');
        }
{
class AdminController extends Controller
{
    public function capnhatkm()
    {
        $this->assign('list_km',$this->_model->getCapnhatkm());

    }
    public function xoakm($id=null)
    {

        $this->assign('list_km', $this->_model->getDelete($id));
        $this->assign('list_km',$this->_model->getCapnhatkm());

    }
   public function themkm($id)
    {

       $this->assign('list_km', $this->_model->getThemkm_quatang());
        $this->assign('list_km', $this->_model->getThemkm_giatri($id));
       $this->assign('list_km', $this->_model->getCapnhatkm());
    }
    public function formsuakm($id=null)
    {
        $this->assign('rows', $this->_model->getFormsuakm($id));

        $this->assign('id', $id);
    }


   public function suakm($id)
    {

        $this->assign('rows', $this->_model->getSuakm($id));
        $this->assign('id', $id);
        $this->assign('list_km', $this->_model->getCapnhatkm());
    }

    public function formthemquatang()
    {
        $this->assign('list_qt',$this->_model->getQuatangform());
    }
    public  function themqt()
    {
        $this->assign('list_qt', $this->_model->getThemqt());
        $this->assign('list_km', $this->_model->getCapnhatkm());

    }
    public function xoaqt($id=null)
    {
        $this->assign('list_qt', $this->_model->getXoaqt($id));
        $this->assign('list_qt', $this->_model->getQuatangform());
    }
    public function formthemkm_qt()
    {
     //   $this->assign('list_dt',$this->_model->getDienthoaikm());

        $this->assign('list_qtkm',$this->_model->getDsctkm());
        $this->assign('list_dtkm',$this->_model->getDsdienthoai());
        $this->assign('list_qt',$this->_model->getDsquatang());
    }
    public function themkm_qt()
    {

        $this->assign('list_qt',$this->_model->getThemkm_qt());
        $this->assign('list_km',$this->_model->getCapnhatkm());

    }
    public function xoadt_km($id)
    {

        $this->assign('list_dt',$this->_model->getXoadt_km($id));
        $this->assign('list_dt',$this->_model->getXoactqt($id));
        $this->assign('list_km',$this->_model->getCapnhatkm());
    }
    public function formthemkm_giatri()
    {
        $this->assign('list_gtkm',$this->_model->getGiatrikm());
        $this->assign('list_dtkm',$this->_model->getDsdienthoai());
        $this->assign('list_gtkm',$this->_model->getDsgiatrikm());
    }

   public function themkm_giatri()
    {

       $this->assign('',$this->_model->getThemkm_gt());
        $this->assign('list_km', $this->_model->getCapnhatkm());
    }
    public function xoagt($id)
    {
        $this->assign('list_gtkm', $this->_model->getXoagt($id));
        $this->assign('list_km',$this->_model->getCapnhatkm());
    }



    //showkm
    public function showkm($idkm)
    {
      //  $this->assign('list_km',$this->_model->getCapnhatkm());
        $this->assign('list_dtkm',$this->_model->getDsdienthoai());
        $this->assign('list_gtkm',$this->_model->getDsgiatrikm());
 //       $this->assign('sql',$this->_model->getThemkm_gt());
        $this->assign('list_qtkm',$this->_model->getDsctkm());
        $this->assign('list_qt',$this->_model->getDsquatang());
     //   $this->assign('sql',$this->_model->getThemkm_qt());
        $loai_giatri = true;
        $dt = new Dienthoai();
        $data = $this->_model->getChiTietkm($idkm, $loai_giatri);
        $this->assign('km_giatri', $loai_giatri);

        foreach ($data as &$item) {

            $item['h_url'] = $dt->getDienthoaiFirstImage($item['dt_id']);
        }

        $this->assign(array(
            'list' => $data,
            'km_ten' => $this->_model->getTenKm($idkm)
        ));
    }



}
}